<template>
  <div class="all-evaluate">
    <van-nav-bar title="课程评价" @click-left="$router.go(-1)" class="app-van-nav-bar">
      <x-svg-icon slot="left" name="arrow_back" />
    </van-nav-bar>
    <div class="list">
      <div class="mobile-course-introduce" v-for="(item, i) in evaluateList" :key="`evaluate${i}`">
        <div class="introduce-text mobile-teacher-img" style="padding-top: 0">
          <div class="img">
            <img :src="item.userPic">
          </div>
          <div class="name">
            <div class="name-wrap-text">{{ item.userName }}</div>
            <div class="teacher-title">{{ item.createTime }}</div>
          </div>
        </div>
        <div class="evaluate-text">{{ item.comments }}</div>
      </div>
    </div>
    <van-pagination v-model="currentPage" :total-items="total" :items-per-page="pageSize" @change="currentChange" :prev-text="prevText" :next-text="nextText" />
  </div>
</template>

<script>
  export default {
    name: 'allEvaluate',
    data() {
      return {
        evaluateList: [],
        total: 0,
        currentPage: 1,
        pageSize: 20,
        courseId: this.$route.query.id, // 课程id
        prevText: '<',
        nextText: '>',
      };
    },
    mounted() {
      this.getList();
    },
    methods: {
      /**
       * 获取评论列表
       **/
      async getList(){
        const { data, total } = await this.Request.pageCourseComment({
          params: {
            courseId: this.courseId,
            currentPage: this.currentPage,
            pageSize: this.pageSize,
          },
        });
        this.evaluateList = data;
        this.total = total;
      },
      currentChange(val){
        this.currentPage = val;
        this.getList();
      },
    },
  };
</script>

<style lang="scss" scoped>
  .all-evaluate{
    padding-bottom: 0.5rem;
  }
  .list{
    padding: 0 0.579rem;
    height: calc(100vh - 20px - 46px - 40px - 0.5rem);
    overflow-y: auto;
  }
  .mobile-course-introduce{
    /*margin-bottom: 0.926rem;*/
    border-bottom: 1px solid #e3e3e3;
    padding: 0.683rem 0 1.076rem;
    .introduce-text{
      font-size: 0.555rem;
      font-weight: 500;
      color: #333333;
      padding-bottom: 0.555rem;
      border-bottom: 1px solid #e3e3e3;
      margin-bottom: 0.532rem;
    }
    .introduce-wrap{
      position: relative;
      .introduce-wrap-text{
        font-size: 0.486rem;
        font-weight: 400;
        color: #333333;
        line-height: 0.694rem;
        padding: 0 0.579rem;
        max-height: 4.63rem;
        overflow: hidden;
        &.active{
          max-height: none;
          &::after{
            display: none;
          }
        }
        &::after{
          content: "";
          position: absolute;
          bottom: 0;
          left: 0;
          right: 0;
          height: 1.7rem;
          background: linear-gradient(to bottom, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 140%);
        }
      }
      .see-more{
        width: 3.6rem;
        left: 50%;
        margin-left: -1.8rem;
        position: absolute;
        display: flex;
        justify-content: center;
        font-size: 0.486rem;
        font-weight: 400;
        color: #1D67FF;
        align-items: center;
        .svg-icon{
          margin-left: 0.278rem;
        }
      }
    }
    .mobile-teacher-img{
      display: flex;
      border-bottom: none;
      margin-bottom: 0;
      .img{
        width: 2.176rem;
        height: 2.176rem;
        background: #BFE1EB;
        border-radius: 50%;
        overflow: hidden;
        display: flex;
        justify-content: center;
        margin-right: 0.451rem;
        img{
          height: 100%;
        }
      }
      .name{
        display: flex;
        flex-flow: column;
        justify-content: center;
        .name-wrap-text{
          font-size: 0.694rem;
          font-weight: 500;
          color: #333333;
        }
        .teacher-title{
          font-size: 0.486rem;
          font-weight: 400;
          color: #999999;
        }
      }
    }
  }
  .evaluate-text{
    font-size: 0.486rem;
    font-weight: 400;
    color: #333333;
    line-height: 0.694rem;
  }
</style>
